<?php
class ProductImage extends Model {
	public function addImage($product_id,$image,$thumbnail) {
		return $this->dbo->query("INSERT INTO product_image (product_id,image,thumbnail) VALUES ('".(int)$product_id."','".$this->dbo->escape($image)."','".$this->dbo->escape($thumbnail)."')");
	}
	public function delProductImgByPid($product_id){
		return $this->dbo->query("DELETE FROM product_image WHERE product_id='".(int)$product_id."'");
	}
	public function getProductImgByPid($product_id){
		$result = $this->dbo->query("SELECT product_image_id,image,thumbnail FROM product_image WHERE product_id='".(int)$product_id."'");
		return $result->rows;
	}
	public function delProductImgByImageIds($image_ids) {
		return $this->dbo->query("DELETE FROM product_image WHERE product_image_id IN($image_ids)");
	}
	public function getProductImgByImageIds($image_ids){
		$result = $this->dbo->query("SELECT product_image_id,image,thumbnail FROM product_image WHERE product_image_id IN($image_ids)");
		return $result->rows;
	}
}
?>